package com.qf.qflivehou.controller;

import com.qf.qflivehou.pojo.reqVo.OrderReq;
import com.qf.qflivehou.pojo.reqVo.OrderReq2;
import com.qf.qflivehou.pojo.respVo.ResponseData;
import com.qf.qflivehou.service.OrderService;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Mr.Liu
 * @date 2022/1/12 19:57
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;

    /**
     * 添加订单
     * @param orderReq
     * @param request
     * @return
     */
    @RequestMapping("/addOrder")
    public ResponseData addOrder(@RequestBody OrderReq orderReq, HttpServletRequest request){
        ResponseData responseData = orderService.addOrder(orderReq,request);
        return responseData;
    }

    /**
     * 查找用户订单,回显订单数据
     * @param request
     * @return
     */
    @RequestMapping("/findOrderByUserId")
    public ResponseData findOrderByUserId(HttpServletRequest request){
        ResponseData responseData = orderService.findOrderByUserId(request);
        return responseData;
    }

    /**
     * 删除用户订单
     * @param orderReq2
     * @return
     */
    @PostMapping("/cancelPay")
    public ResponseData cancelPay(@RequestBody OrderReq2 orderReq2){
        ResponseData responseData = orderService.cancelPay(orderReq2);
        return responseData;
    }

    @RequestMapping("/findOldOrderByUserId")
    public ResponseData findOldOrderByUserId(HttpServletRequest request){
        ResponseData responseData =orderService.findOldOrderByUserId(request);
        return responseData;
    }
}
